<?php

namespace Modules\Admin\Http\Controllers;

use Illuminate\Support\Facades\Request;
use Modules\Admin\Service\InviteService;
use Modules\Admin\Service\CouponService;


class InviteController extends BaseController
{


	/**
	 *	获取邀请的参数
	 *	hinq 2019 08 29
	 *
	 **/
	public function index(){
		$arr_search = (array)Request::input();
		$arr_list = InviteService::get_list( (array) $arr_search );
		echo_error($arr_list);
        return view('admin::invite.index',$arr_list['data']);
	}


	/**
	 *	设置邀请参数
	 *	hinq 2019 08 29
	 *
	 **/
	public function set(){

		//获取邀请参数
		$arr_info = InviteService::get_one()->toArray();
		//获取当前用户添加的优惠券
        $arrWhere['where'] = ['admin_id'=>admin_user_id(),'status'=>1];
        $arrWhere['field'] = ['id','name'];
        $coupon_list = CouponService::get_where_list( (array) $arrWhere );
        return view('admin::invite.set',['coupon_list'=>$coupon_list , 'arr_info'=>$arr_info]);
	}


	/**
	 *	更新邀请参数
	 *	hinq 2019 08 29
	 *
	 **/
	public function update(){
		$arrInput = (array) Request::all();
		return InviteService::edit_one( (array) $arrInput );
	}


}